package StudyCode.summary.myfile;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CreateTempFileContainStr {
	public static void main(String[] argv) throws Exception {
		String contents = "tah1986.com";
		System.out.println(createTempFile(contents));
	}

	private static String createTempFile(String contents) throws IOException {
		File f = File.createTempFile("flink_test_", ".tmp");
		f.deleteOnExit();

		try (BufferedWriter out = new BufferedWriter(new FileWriter(f))) {
			out.write(contents);
		}
		return f.toURI().toString();
	}
}
